from django.template.loader import render_to_string
from django.shortcuts import render


def index(request):
    # html = render_to_string("index.html")
    # return HttpResponse(html)
    # 字典
    # text = {
    #     "name": {
    #         "first": "di",
    #         "last": "mingda"
    #     }
    # }
    # {{name.first}}
    # list
    # text = {
    #     "name":[
    #         1,
    #         2,
    #         3
    #     ]
    # }
    # {{name.0}}

    # if语句
    # text = {
    #     "age": 13
    # }

    # for语句
    # text = {
    #     "name": [
    #         "di",
    #         "mingda",
    #         "shuai"
    #     ],
    #     "age": {
    #         "da": 11,
    #         "xiao": 22
    #     }
    # }
    text = {
        "book": [
            {
                "name": "西游记",
                "people": "孙悟空",
                "price": 199
            },
            {
                "name": "水浒传",
                "people": "宋江",
                "price": 12
            },
            {
                "name": "三国",
                "people": "刘备",
                "price": 99
            }
        ]
    }
    return render(request, "index.html", context=text)
